<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:c="http://java.sun.com/jsp/jstl/core"> 

<ui:composition template="../template.xhtml">
		<ui:define name="conteudo">
			<p:ajaxStatus onstart="statusDialog.show();" onsuccess="statusDialog.hide();"/>
				<p:dialog modal="true" widgetVar="statusDialog" header="Status"   
			        draggable="false" closable="false">  
				    <h:outputText value="Aguarde..." /> 
			</p:dialog>  
			<div id="location">Manter Cliente</div>
			<div id="container">
       			<div id="form">
       				<h:form id="clienteForm">
       					<h:inputHidden value="#{clienteMB.cliente.id}" />
       					<p:messages id="growl" showDetail="true" showSummary="false" />
       					<fieldset>
       						<fieldset>
							<legend>Dados</legend>
	       					<table width="70%" align="left">
       							<tr>
       								<td>
       									<label>
			       							<p>Tipo Pessoa:</p>
			       							<h:selectOneMenu value="#{clienteMB.cliente.tipoPessoa}" style="width:100px" onkeydown="if(event.keyCode==13) event.keyCode=9;" required="true" requiredMessage="Tipo Pessoa é Obrigatório!">
			       								<f:selectItem itemLabel="Física" itemValue="PF"/>
			       								<f:selectItem itemLabel="Jurídica" itemValue="PJ"/>
			       							</h:selectOneMenu>
			       						</label>
       								</td>
       								<td>
       									<label>
				       						<p>CPF/CNPJ:</p>
				       						<p:inputText value="#{clienteMB.cliente.cdPess}" style="width:120px" onkeydown="if(event.keyCode==13) event.keyCode=9;" maxlength="14" required="true" requiredMessage="- Digite o CPF/CNPJ."/>
				       					</label>
       								</td>
       								<td>
       									<label>
				       						<p>Tipo Cliente:</p>
				       						<h:selectOneMenu value="#{clienteMB.cliente.idTipoCliente}" style="width:150px" required="true" requiredMessage="Tipo Cliente é Obrigatório!">
				       							<f:selectItem itemLabel="Selecione" itemValue=""/>
				       							<f:selectItems value="#{clienteMB.tipoClienteList}" var="tip" itemLabel="#{tip.dsTipoCliente}" itemValue="#{tip.id}"/>
				       						</h:selectOneMenu>
				       					</label>
       								</td>       								
      								<td>
       									<label>
				       						<p>Nome:</p>
				       						<p:inputText value="#{clienteMB.cliente.nome}" style="width:200px" maxlength="55" onkeydown="if(event.keyCode==13) event.keyCode=9;" required="true" requiredMessage="- Digite o Nome."/>
				       					</label>
       								</td>
       							</tr>
       							<tr>
       								<td>
       									<label>
				       						<p>Nº Identidade:</p>
				       						<p:inputText value="#{clienteMB.cliente.rg}" style="width:200px" maxlength="20" onkeydown="if(event.keyCode==13) event.keyCode=9;"/>
				       					</label>
       								</td>
       								<td>
       									<label>
				       						<p>C.N.H.:</p>
				       						<p:inputText value="#{clienteMB.cliente.cnh}" style="width:200px" maxlength="20" onkeydown="if(event.keyCode==13) event.keyCode=9;"/>
				       					</label>
       								</td>
       								<td>
       									<label>
				       						<p>Validade C.N.H.:</p>
				       						<p:calendar value="#{clienteMB.cliente.validadeCnh}" pattern="dd/mm/yyyy"/>
				       					</label>
       								</td>
       								<td>
       									<label>
				       						<p>Carro Reserva?:</p>
			       							<h:selectOneMenu value="#{clienteMB.cliente.carroReserva}" style="width:100px" onkeydown="if(event.keyCode==13) event.keyCode=9;">
			       								<f:selectItem itemLabel="Não" itemValue="N"/>
			       								<f:selectItem itemLabel="Sim" itemValue="S"/>
			       							</h:selectOneMenu>
				       					</label>
       								</td>
 								</tr>
 							</table>
 							</fieldset>
 							<fieldset>
 							<legend>Endereço</legend>
	       					<table width="70%" align="left">	      								
       							<tr>	
       								<td>
       									<label>
				       						<p>CEP:</p>
				       						<p:inputMask mask="99.999-999" value="#{clienteMB.cliente.cep}"  maxlength="8" style="width:100px" onkeydown="if(event.keyCode==13) event.keyCode=9;"/>
				       					</label>
       								</td>
       								<td>
       									<label>
				       						<p>Estado:</p>
				       						<h:selectOneMenu value="#{clienteMB.idEstado}" onkeydown="if(event.keyCode==13) event.keyCode=9;">
				       							<f:selectItem itemLabel="Selecione" itemValue=""/>
				       							<f:selectItems value="#{clienteMB.estadoList}" var="est" itemLabel="#{est.nome} - #{est.sigla}" itemValue="#{est.id}"/>
				       							<p:ajax update="cidade" listener="#{clienteMB.listaCidades}" />  
				       						</h:selectOneMenu>
				       					</label>
       								</td>
       								<td>
       									<label>
				       						<p>Cidade:</p>
				       						<h:selectOneMenu value="#{clienteMB.cliente.idCidade}" id="cidade" onkeydown="if(event.keyCode==13) event.keyCode=9;">
				       							<f:selectItem itemValue="" itemLabel="Selecione"/>
				       							<f:selectItems value="#{clienteMB.cidadeList}" var="cid" itemLabel="#{cid.nome}" itemValue="#{cid.id}"/>
				       						</h:selectOneMenu>
				       					</label>
       								</td>
       								<td>
       									<label>
				       						<p>Bairro:</p>
				       						<p:inputText value="#{clienteMB.cliente.bairro}" style="width:150px" maxlength="20" onkeydown="if(event.keyCode==13) event.keyCode=9;"/>
				       					</label>
       								</td>
       							</tr>
       							<tr>
       								<td colspan="2">
       									<label style="width: 320px;">
				       						<p>Logradouro:</p>
				       						<p:inputText value="#{clienteMB.cliente.logradouro}" style="width:320px" maxlength="100" onkeydown="if(event.keyCode==13) event.keyCode=9;"/>
				       					</label>
       								</td>
       								<td>
       									<label>
				       						<p>Número:</p>
				       						<p:inputText value="#{clienteMB.cliente.numero}" style="width:100px" maxlength="11" onkeydown="if(event.keyCode==13) event.keyCode=9;"/>
				       					</label>
       								</td>
       								<td>
       									<label>
				       						<p>Complemento:</p>
				       						<p:inputText value="#{clienteMB.cliente.complemento}" style="width:100px" maxlength="20" onkeydown="if(event.keyCode==13) event.keyCode=9;"/>
				       					</label>
       								</td>
       							</tr>
       						</table>
       						</fieldset>
       						<fieldset>
 							<legend>Contato</legend>
	       					<table width="50%" align="left">
       							<tr>
       								<td>
       									<label>
				       						<p>Email:</p>
				       						<p:inputText value="#{clienteMB.cliente.email}" style="width:200px" maxlength="50" onkeydown="if(event.keyCode==13) event.keyCode=9;"/>
				       					</label>
       								</td>
       								<td>
       									<label>
				       						<p>Telefone Res:</p>
				       						<p:inputMask mask="(99) 9999-9999" value="#{clienteMB.cliente.telefoneRes}"  maxlength="10" style="width:100px" onkeydown="if(event.keyCode==13) event.keyCode=9;"/>
				       					</label>
       								</td>
       								<td>
       									<label>
				       						<p>Telefone Cel.:</p>
				       						<p:inputMask mask="(99) 9999-9999" value="#{clienteMB.cliente.telefoneCel}"   maxlength="10" style="width:100px" onkeydown="if(event.keyCode==13) event.keyCode=9;"/>
				       					</label>
       								</td>
      								<td>
       									<label>
				       						<p>Telefone Com.:</p>
				       						<p:inputMask mask="(99) 9999-9999" value="#{clienteMB.cliente.telefoneCom}"   maxlength="10" style="width:100px" onkeydown="if(event.keyCode==13) event.keyCode=9;"/>
				       					</label>
       								</td>       								
       								<td>&nbsp;</td>
       							</tr>
       						</table>
       					</fieldset>
       						<p:spacer height="20"/>
			       				<div align="right" style="padding-right: 20px; padding-bottom: 10px;">
			       					<p:commandButton value="Salvar" action="#{clienteMB.saveOrUpdate}" update="growl clienteForm"/>
			       					<p:spacer width="10"/>
			       					<p:commandButton value="Voltar" action="#{clienteMB.paginaBusca}" ajax="false" immediate="true"/>
			       				</div>
       					</fieldset>
       				</h:form>
       			</div>
       		</div>
		</ui:define>
</ui:composition>		
</html>